package org.vy.dal.dao;

import java.util.List;

import org.vy.dal.QueryManager;

public class VyPrintLabelReportDAO {
	private static final String FIND_BY_REPORT_ID = "SELECT * FROM <TABLE> WHERE REPORT_ID = m_ReportId";
	private static final String FIND_BY_CRITERIA = "SELECT * FROM <TABLE> WHERE CRITERIA = m_Criteria";
	private static final String FIND_ALL = "SELECT * FROM <TABLE>";
	private static final String UPDATE = "UPDATE <TABLE> SET REPORT_NAME = m_ReportName,REPORT_TYPE = m_ReportType,CRITERIA = m_Criteria,IS_ACTIVE = m_IsActive,IS_AUTORUN = m_IsAutorun,SCHEDULE_FREQUENCY = m_ScheduleFrequency,SCHEDULE_MIN = m_ScheduleMin,SCHEDULE_HOUR = m_ScheduleHour,SCHEDULE_DAY = m_ScheduleDay,SCHEDULE_MONTH = m_ScheduleMonth,SCHEDULE_WEEKDAY = m_ScheduleWeekday,EXPIRY_DATE = m_ExpiryDate,LAST_MODIFIED_BY = m_LastModifiedBy,LAST_MODIFIED_ON = m_LastModifiedOn WHERE REPORT_ID = m_ReportId";
	private static final String INSERT = "INSERT INTO <TABLE> (REPORT_ID,REPORT_NAME,REPORT_TYPE,CRITERIA,IS_ACTIVE,IS_AUTORUN,SCHEDULE_FREQUENCY,SCHEDULE_MIN,SCHEDULE_HOUR,SCHEDULE_DAY,SCHEDULE_MONTH,SCHEDULE_WEEKDAY,EXPIRY_DATE,CREATED_DATE,LAST_MODIFIED_BY,LAST_MODIFIED_ON)VALUES(m_ReportId,m_ReportName,m_ReportType,m_Criteria,m_IsActive,m_IsAutorun,m_ScheduleFrequency,m_ScheduleMin,m_ScheduleHour,m_ScheduleDay,m_ScheduleMonth,m_ScheduleWeekday,m_ExpiryDate,m_CreatedDate,m_LastModifiedBy,m_LastModifiedOn);";
	private static final String DELETE = "DELETE FROM <TABLE> WHERE REPORT_ID = m_ReportId";

	@SuppressWarnings("unchecked")
	public static List<VyPrintLabelReportDO> findAll() throws Exception {
		VyPrintLabelReportDO dto = new VyPrintLabelReportDO();
		return (List<VyPrintLabelReportDO>) QueryManager.executeListQuery(dto,
				FIND_ALL);
	}

	public static VyPrintLabelReportDO findByReportId(int reportId)
			throws Exception {
		VyPrintLabelReportDO dto = new VyPrintLabelReportDO();
		dto.setReportId(reportId);
		dto = (VyPrintLabelReportDO) QueryManager.executeQuery(dto,
				FIND_BY_REPORT_ID);
		return dto;
	}

	public static VyPrintLabelReportDO findByCriteria(String criteria)
			throws Exception {
		VyPrintLabelReportDO dto = new VyPrintLabelReportDO();
		dto.setCriteria(criteria);
		dto = (VyPrintLabelReportDO) QueryManager.executeQuery(dto,
				FIND_BY_CRITERIA);
		return dto;
	}

	public static VyPrintLabelReportDO insert(VyPrintLabelReportDO dto)
			throws Exception {
		dto = (VyPrintLabelReportDO) QueryManager.executeInsert(dto, INSERT);
		return dto;
	}

	public static VyPrintLabelReportDO update(VyPrintLabelReportDO dto)
			throws Exception {
		int i = QueryManager.executeUpdate(dto, UPDATE);
		if (i > 0)
			return dto;
		else
			return null;
	}

	public static boolean delete(VyPrintLabelReportDO dto) throws Exception {
		boolean i = QueryManager.executeDelete(dto, DELETE);
		return i;
	}
}
